RESTful API


Posted by tzutzu858 on 2020-10-27

REST ( Representational State Transfer ) 表現層狀態轉移

是一種設計風格

讓大家可以立刻就知道這個 API 是做什麼用的

RESTful API 從以下三個方面資源進行定義::

  1. Verbs:要對資源做的動作。
  2. Nouns:資源位置的 URL
  3. Content Types:最常用的是 JSON

像是 GET http://blog.tw/comment/1,就會立刻可以理解他要取得 http://blog.tw/comment 網站中,編號 1、名為 comment 的資源。

或是列舉所有商品

GET http://www.store.com/products

呈現某一件商品

GET http://www.store.com/products/12345


來源 : 表現層狀態轉換(維基百科)

不過 php 要遵照這個風格要在 Apache 那邊做一些設定,不過如果不遵照這個規則就是自己命名就好,像是之前留言版的 api_comments.php










Related Posts

MPLAB X IDE 黑色主題

MPLAB X IDE 黑色主題

資料傳輸物件Data Transfer Object(DTO) 簡介

資料傳輸物件Data Transfer Object(DTO) 簡介

Secure Apache Using Certbot with Let's Encrypt on Ubuntu 20.04

Secure Apache Using Certbot with Let's Encrypt on Ubuntu 20.04


Comments